package com.ruoyi.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.mapper.AdsRecoverStationMapper;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.domain.AdsRecoverStation;
import com.ruoyi.service.IAdsRecoverStationService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 行政审批回收站Controller
 * 
 * @author ya
 * @date 2025-08-27
 */
@RestController
@RequestMapping("/adsRecoverStation/station")
public class AdsRecoverStationController extends BaseController
{
    @Autowired
    private IAdsRecoverStationService adsRecoverStationService;


    /**
     * 恢复数据到文章表
     */
    @PostMapping("/recoverData/{recoverIds}")
    public AjaxResult recoverData(@PathVariable Long[] recoverIds){
        if (recoverIds == null || recoverIds.length == 0) {
            return error("请选择要恢复的数据");
        }
        // 返回操作结果和恢复数量
        AjaxResult ajaxResult = AjaxResult.success();
        int count = adsRecoverStationService.recoverData(recoverIds);
        ajaxResult.put("msg", "成功恢复 " + count + " 条数据");

        return ajaxResult;
    }

    /**
     * 查询行政审批回收站列表
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:list')")
    @GetMapping("/list")
    public TableDataInfo list(AdsRecoverStation adsRecoverStation)
    {
        startPage();
        List<AdsRecoverStation> list = adsRecoverStationService.selectAdsRecoverStationList(adsRecoverStation);
        return getDataTable(list);
    }

    /**
     * 导出行政审批回收站列表
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:export')")
    @Log(title = "行政审批回收站", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AdsRecoverStation adsRecoverStation)
    {
        List<AdsRecoverStation> list = adsRecoverStationService.selectAdsRecoverStationList(adsRecoverStation);
        ExcelUtil<AdsRecoverStation> util = new ExcelUtil<AdsRecoverStation>(AdsRecoverStation.class);
        util.exportExcel(response, list, "行政审批回收站数据");
    }

    /**
     * 获取行政审批回收站详细信息
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(adsRecoverStationService.selectAdsRecoverStationById(id));
    }

    /**
     * 新增行政审批回收站
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:add')")
    @Log(title = "行政审批回收站", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AdsRecoverStation adsRecoverStation)
    {
        return toAjax(adsRecoverStationService.insertAdsRecoverStation(adsRecoverStation));
    }

    /**
     * 修改行政审批回收站
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:edit')")
    @Log(title = "行政审批回收站", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AdsRecoverStation adsRecoverStation)
    {
        return toAjax(adsRecoverStationService.updateAdsRecoverStation(adsRecoverStation));
    }

    /**
     * 删除行政审批回收站
     */
    @PreAuthorize("@ss.hasPermi('adsRecoverStation:station:remove')")
    @Log(title = "行政审批回收站", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(adsRecoverStationService.deleteAdsRecoverStationByIds(ids));
    }
}
